< previous page page_354 next page >

Page 354
(table continued from previous page)
C DATA TYPEVISUAL BASIC EQUIVALENT
longLong
floatSingle
doubleDouble
class, structUser-defined type
Table T6-5: VB equivalents to the base C data types

Handling Signed and Unsigned Types
The C char data type is 8 bits wide, thus you would use the Visual Basic Byte data type for both signed and unsigned chars. The trick to handling these data types is to recognize the range limitations that occur during the conversion process.
Let's say you had a C structure defined that included a signed char, and you needed to set it to 50.
struct myStruct {
char myChar;
}
The Visual Basic equivalent structure is:
Type myStruct
myChar As Byte
End Type
If you tried to assign:
Dim S As myStruct
S.myChar = -50
you would get a range overflow error, because the Byte variable is unsigned and cannot be set to a negative number.

 
< previous page page_354 next page >